//
//  NGHomeListPicAdCell.swift
//  NingguoForum
//
//  Created by zhengsw on 2022/11/9.
//  Copyright © 2022 zhengsw. All rights reserved.
//

import UIKit
import SnapKit
import Kingfisher
class NGHomeListPicAdCell: UITableViewCell {

    let showTitleLabel: UILabel! //标题
    let titleLable: UILabel! //来源
    let infoImg: UIImageView! //图片
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        
        titleLable = UILabel()
        showTitleLabel = UILabel()
        infoImg = UIImageView()
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        selectionStyle = .none
        
        showTitleLabel.text = "--";
        showTitleLabel.font = UIFont.systemFont(ofSize: 15)
        showTitleLabel.numberOfLines = 2;
        contentView.addSubview(showTitleLabel)
        
        titleLable.text = "--";
        titleLable.font = UIFont.systemFont(ofSize: 10)
        titleLable.textColor = RGB_COLOR(r: 175, g: 175, b: 175)
        contentView.addSubview(titleLable)

        infoImg.image = UIImage.init()
        infoImg.contentMode = .scaleToFill
        contentView.addSubview(infoImg)

        showTitleLabel.snp.makeConstraints { (make) ->Void  in
            make.top.equalToSuperview().offset(5)
            make.left.equalTo(contentView).offset(20)
            make.right.equalToSuperview().offset(-20)
        }
        
        titleLable.snp.makeConstraints { (make) ->Void in
            make.left.equalTo(contentView).offset(20)
            make.right.equalTo(contentView).offset(-20)
            make.bottom.equalTo(contentView).offset(-10)
        }
        
        infoImg.snp.makeConstraints { (make) ->Void in
            make.top.equalTo(showTitleLabel.snp_bottom).offset(5)
            make.left.equalTo(contentView).offset(20)
            make.right.equalTo(contentView).offset(-20)
            make.bottom.equalTo(titleLable.snp_top).offset(-5)
        }

    }
    func setModel(model: HomeListModel){

        titleLable.text = model.title
        showTitleLabel.text = model.show_title

        let urlDict = model.pics_arr.first as! [String : Any]
        let pic = urlDict["url"] as! String
        
        infoImg.kf.setImage(with: URL(string: pic));
        
    }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
